import { stringify } from 'qs';
import request from '@/utils/request';

/**
 *  Created by xjc on 2019/5/20
 *  Describe:权限系统
 */

// user
export async function GetUserList(params) {
  return request('/fss/User/UserList', {
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
  });
}
export async function FreezeUserList(params) {
  return request(`/fss/User/StopUser?id=${params.id}`, {
    method: 'GET',
  });
}
export async function ChangeUserList(params) {
  return request('/fss/User/UpdateUserRole', {
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
  });
}

// Authority
export async function AddAuthorityList(params) {
  return request('/fss/Role/AddRole', {
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
  });
}
export async function GetAuthorityList(params) {
  return request('/fss/Role/RoleList', {
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
  });
}
export async function ChangeAuthorityDetail(params) {
  return request('/fss/Role/UpdateRole', {
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
  });
}
export async function RemoveAuthorityList(params) {
  return request(`/fss/Role/DelRole?id=${params.id}`, {
    method: 'GET',
  });
}
export async function GetAuthorityPermissionById(params) {
  return request(`/fss/Role/SelectPermission?id=${params.id}`, {
    method: 'GET',
  });
}
export async function GetAuthorityPermission(params) {
  return request('/Permission/PermissionList', {
    method: 'GET',
  });
}
export async function UpdateRolePermission(params) {
  return request('/fss/Role/UpdateRolePermission', {
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
  });
}

// menu
export async function GetMenuList(params) {
  return request('/fss/Permission/PermissionList', {
    method: 'GET',
  });
}
export async function DelMenuList(params) {
  return request(`/fss/Permission/DelPermission?id=${params.id}`, {
    method: 'GET',
  });
}
export async function ChangeMenuDetail(params) {
  return request('/fss/Permission/UpdatePermission', {
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
  });
}
export async function AddMenuList(params) {
  return request('/fss/Permission/AddPermission', {
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
  });
}
